package com.springboot.exception;

import com.springboot.dto.resp.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result<String> handleException (Exception e){
        // 记录异常日志
        log.error("Error occurred", e);
        // 返回失败结果
        return Result.failure(400, "Failed to process request");
    }
}
